326. 3 的幂
为保证权益,题目请参考 326. 3 的幂(From LeetCode).
解决方案1
CPP
C++
#include <iostream>
using namespace std;
class Solution {
public:
static bool isPowerOfThree(int n) {
return n > 0 && 1162261467%n == 0;
}
};
int main() {
int t;
for (int i = 1; i < 30; i++) {
t = pow(3, i);
cout << "# " << i << ": " << t << endl;
}
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19